home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / mou105.arc / TEST.C < prev    next >
C/C++ Source or Header  |  1991-09-29  |  4KB  |  111 lines

  1. /*****************************************************************************
  2.  * PROJECT:  Mouse routines with 'real' graphic cursor in text mode.
  3.  *****************************************************************************
  4.  * MODULE:  TEST.C
  5.  *****************************************************************************
  6.  * DESCRIPTION:
  7.  *   Test program.
  8.  *
  9.  *****************************************************************************
  10.  * MODIFICATION NOTES:
  11.  *    Date     Author Comment
  12.  * 26-Oct-1990     dk   Initial file.
  13.  * 07-Jan-1991     dk   Fixed bugs and set up for release to Usenet.
  14.  *****************************************************************************
  15.  *
  16.  * DISCLAIMER:
  17.  *
  18.  * Programmers may incorporate any or all code into their programs, 
  19.  * giving proper credit within the source. Publication of the 
  20.  * source routines is permitted so long as proper credit is given 
  21.  * to Dave Kirsch.
  22.  *
  23.  * Copyright (C) 1990, 1991 by Dave Kirsch.  You may use this program, or
  24.  * code or tables extracted from it, as desired without restriction.
  25.  * I can not and will not be held responsible for any damage caused from
  26.  * the use of this software.
  27.  *
  28.  *****************************************************************************
  29.  * This source works with Turbo C 2.0 and MSC 6.0 and above.
  30.  *****************************************************************************/
  31.  
  32. #include <stdio.h>
  33.  
  34. #ifdef __TURBOC__
  35. #include <stdlib.h>
  36. #include <bios.h>
  37. #endif
  38.  
  39. #include "mou.h"
  40.  
  41. MOUINFOREC m;
  42.  
  43. int cdecl main(void)
  44. {
  45. word oldmx = -1, oldmy = -1;
  46.  
  47.   MOUinit();
  48.   MOUshow();
  49.  
  50.   if (!mouseinstalled) {
  51.     printf("Please install your mouse driver before running this test "
  52.        "program.\n");
  53.     return 0;
  54.   }
  55.  
  56.   MOUhide();
  57.   printf("\x1b[2J"); /* Clear the screen with ANSI code. */
  58.  
  59.   printf("\x1b[5;1HClick here [■] with left mouse button to quit.");
  60. #ifdef __TURBOC__
  61.   printf("\x1b[7;1HMouse routine demonstration program [Turbo C2.0 Version].");
  62. #else
  63.   printf("\x1b[7;1HMouse routine demonstration program [Microsoft C6.0 Version].");
  64. #endif
  65.   printf("\x1b[8;1HWith 'true' EGA/VGA mouse cursor.");
  66.   printf("\x1b[9;1HCopyright (C) 1990, 1991 by Dave Kirsch [a563@mindlink.UUCP].");
  67.   MOUshow();
  68.  
  69.   for (;;) {
  70.     if (mousex != oldmx || mousey != oldmy) {
  71.       oldmx = mousex;
  72.       oldmy = mousey;
  73.       MOUconditionalhide(0, 0, 50, 0);
  74.       printf("\x1b[1;1HMouse position: %3d, %3d", mousex, mousey);
  75.       MOUshow();
  76.     }
  77.  
  78. #ifdef __TURBOC__
  79.     if (bioskey(1)) {
  80.       bioskey(0);
  81.       MOUsetpos(random(80), random(25));
  82.     }
  83. #endif
  84.  
  85.     if (MOUcheck()) { /* If mouse event waiting in buffer... */
  86.       MOUget(&m);
  87.       MOUconditionalhide(0, 1, 50, 2);
  88.       if (m.buttonstat & LEFTBPRESS)
  89.     printf("\x1b[2;1HLeft button pressed at %3d, %3d ", m.cx, m.cy);
  90.       if (m.buttonstat & LEFTBRELEASE)
  91.     printf("\x1b[2;1HLeft button released at %3d, %3d", m.cx, m.cy);
  92.       if (m.buttonstat & RIGHTBPRESS)
  93.     printf("\x1b[3;1HRight button pressed at %3d, %3d ", m.cx, m.cy);
  94.       if (m.buttonstat & RIGHTBRELEASE)
  95.     printf("\x1b[3;1HRight button released at %3d, %3d", m.cx, m.cy);
  96.       if (m.buttonstat & MIDBPRESS)
  97.     printf("\x1b[4;1HMiddle button pressed at %3d, %3d ", m.cx, m.cy);
  98.       if (m.buttonstat & MIDBRELEASE)
  99.     printf("\x1b[4;1HMiddle button released at %3d, %3d", m.cx, m.cy);
  100.  
  101.       MOUshow();
  102.  
  103.       if (m.buttonstat & LEFTBPRESS && m.cx > 11 && m.cx < 14 && m.cy == 4) {
  104.     MOUdeinit();
  105.     printf("\x1b[2J"); /* Clear the screen with ANSI code. */
  106.     return 0;
  107.       }
  108.     }
  109.   }
  110. }
  111.